package myPackage;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Text_Convertion {

    public static List<String> remakeListForLogger(List<String> CardTypes) {
		List<String> newList = new ArrayList<String>();
        int maxLengthOfWord = maxLengthOfWord(CardTypes);
        Iterator<String> CardTypesIterator = CardTypes.iterator();
        while (CardTypesIterator.hasNext()) {
        	String nextWord = CardTypesIterator.next();
    		int wordLength = nextWord.length();
        	if ( wordLength < maxLengthOfWord ) {
        		int spaceLength = 0;
        		spaceLength = maxLengthOfWord - wordLength;
        		String space = "";
        		for (int i=0; i<spaceLength; i++){
        			space = space + " ";
        		}
        		nextWord += space;
        	}
        	newList.add(nextWord);
        }
    	return newList;
    }
    
    private static int maxLengthOfWord(List<String> CardTypes){
    	int maxLengthOfWord = 0;
    	Iterator<String> CardTypesIterator = CardTypes.iterator();
    	while (CardTypesIterator.hasNext()) {
    		String nextWord = CardTypesIterator.next();
    		int wordLength = nextWord.length();
    		if ( maxLengthOfWord == 0) {
            	maxLengthOfWord = wordLength;
            } else if (wordLength > maxLengthOfWord) {
            	maxLengthOfWord = wordLength;
            }
    	}
		return maxLengthOfWord;
    }
    
}